/*******************************************************************************
 * File name:  irq.h
 * Description: header file for VIC init functions
 * Project:
 * Target:     LPC2478
 * Compiler:   arm-none-eabi-gcc
 * Date:       2010-10-12
 * Author:     Kuba
 * Based on:   NXP code examples
 *******************************************************************************/
#ifndef IRQ_H_
#define IRQ_H_

/*==============================================================================
 Includes
==============================================================================*/
# include <stdbool.h>
# include "typedef.h"
/*==============================================================================
 Defines
==============================================================================*/

/*==============================================================================
 Globals
==============================================================================*/
enum irqNum {
   irqWDT         = 0,
   irqSWI         = 1,
   irqARM_CORE0   = 2,
   irqARM_CORE1   = 3,
   irqTIMER0      = 4,
   irqTIMER1      = 5,
   irqUART0       = 6,
   irqUART1       = 7,
   irqPWM0_1      = 8,
   irqI2C0        = 9,
   irqSPI0        = 10,    /* SPI and SSP0 share this VIC slot */
   irqSSP0        = 10,
   irqSSP1        = 11,
   irqPLL         = 12,
   irqRTC         = 13,
   irqEINT0       = 14,
   irqEINT1       = 15,
   irqEINT2       = 16,
   irqEINT3       = 17,    /* PORT0 & PORT2 & EINT3 interrupts share this VIC slot */
   irqADC0        = 18,
   irqI2C1        = 19,
   irqBOD         = 20,
   irqEMAC        = 21,
   irqUSB         = 22,
   irqCAN         = 23,
   irqMCI         = 24,
   irqGPDMA       = 25,
   irqTIMER2      = 26,
   irqTIMER3      = 27,
   irqUART2       = 28,
   irqUART3       = 29,
   irqI2C2        = 30,
   irqI2S         = 31
};

enum priority {
   irqHIGHEST_PRIORITY  = 0,
   irqPRIORITY1         = 1,
   irqPRIORITY2         = 2,
   irqPRIORITY3         = 3,
   irqPRIORITY4         = 4,
   irqPRIORITY5         = 5,
   irqPRIORITY6         = 6,
   irqPRIORITY7         = 7,
   irqPRIORITY8         = 8,
   irqPRIORITY9         = 9,
   irqPRIORITY10        = 10,
   irqPRIORITY11        = 11,
   irqPRIORITY12        = 12,
   irqPRIORITY13        = 13,
   irqPRIORITY14        = 14,
   irqLOWEST_PRIORITY   = 15
};

/*==============================================================================
 Global function prototypes
==============================================================================*/
extern void vicInit        (void);

extern bool irqInit        (enum irqNum irqNumber, void *isrAddr, enum priority priority);
extern uint32 irqStatus    (void);
extern uint32 irqEnableCpsr(void);
extern uint32 irqDisableCpsr(void);
extern uint32 irqRestore   (uint32 oldCpsr);

extern bool fiqInit        (enum irqNum fiqNumber, void *isrAddr);
extern uint32 fiqStatus    (void);
extern uint32 fiqEnableCpsr(void);
extern uint32 fiqDisableCpsr(void);
extern uint32 fiqRestore   (uint32 oldCpsr);

extern bool clearIntrpt    (enum irqNum irqNumber);

extern void swiHandler     (void) __attribute__ ((interrupt("SWI")));

/******************************************************************************
* END OF FILE
******************************************************************************/

#endif /* IRQ_H_ */
